package com.gamex.findit.service.impl;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.gamex.findit.dao.ItemPurchaseHistMapper;
import com.gamex.findit.model.ItemPurchaseHist;
import com.gamex.findit.service.ItemPurchaseHistService;

/**
 * 아이템 구매이력
 * @author james
 *
 */
@Service
public class ItemPurchaseHistServiceImpl implements ItemPurchaseHistService{
	
	private static final Logger logger = LoggerFactory.getLogger(ItemPurchaseHistServiceImpl.class);

	@Autowired ItemPurchaseHistMapper itemPurchaseHistMapper;
	
	@Override
	public List<ItemPurchaseHist> getItemPurchaseHist(ItemPurchaseHist itemPurchaseHist) throws Exception{
		List<ItemPurchaseHist> result = null;
		try {
			result = itemPurchaseHistMapper.selectItemPurchaseHist(itemPurchaseHist);
		} catch (Exception e) {
			logger.error(e.getMessage());
			throw e;
		}
		return result;
	}

	@Override
	public int getItemPurchaseHistCount(ItemPurchaseHist itemPurchaseHist) throws Exception{
		int count = 0;
		try {
			count = itemPurchaseHistMapper.selectItemPurchaseHistCount(itemPurchaseHist);
		} catch (Exception e) {
			logger.error(e.getMessage());
			throw e;
		}
		return count;
	}

	@Override
	public ItemPurchaseHist getItemPurchaseHistView(int seq) throws Exception{
		ItemPurchaseHist result = null;
		try {
			result = itemPurchaseHistMapper.selectItemPurchaseHistView(seq);
		} catch (Exception e) {
			logger.error(e.getMessage());
			throw e;
		}
		return result;
	}

	@Override
	public void insertItemPurchaseHist(ItemPurchaseHist itemPurchaseHist) throws Exception{
		try {
			itemPurchaseHistMapper.insertItemPurchaseHist(itemPurchaseHist);
		} catch (Exception e) {
			logger.error(e.getMessage());
			throw e;
		}
	}

	@Override
	public void updateItemPurchaseHist(ItemPurchaseHist itemPurchaseHist) throws Exception{
		try {
			itemPurchaseHistMapper.updateItemPurchaseHist(itemPurchaseHist);
		} catch (Exception e) {
			logger.error(e.getMessage());
			throw e;
		}
		
	}

	@Override
	public void deleteItemPurchaseHist(int seq) {
		try {
			itemPurchaseHistMapper.deleteItemPurchaseHist(seq);
		} catch (Exception e) {
			logger.error(e.getMessage());
		}
		
	}
	
}
